package fpt.edu.vn.action;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

/* 
 * RemoveOneCompareAction.java 
 *  
 * 0.1
 * 
 * 10/15/2012 
 *  
 * Copyright notice 
 *  
 * Modification Logs: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  -------------------------------------------------------- 
 *  15-Oct-2012  ThuongND    Create new 
 */
public class RemoveOneCompareAction extends ActionSupport {

	private static final long serialVersionUID = 1L;

	private int topicId;

	Map<String, Object> session;

	public String execute() {

		session = ActionContext.getContext().getSession();
		if (session.containsKey("number")) {
			Integer number = (Integer) session.get("number");
			number = number - 1;
			StringBuilder topicIds = (StringBuilder) session.get("topicIds");
			String s = topicIds.toString().replaceAll("" + topicId + ",", "");
			StringBuilder newtopicIds = new StringBuilder();
			newtopicIds.append(s);
			session.put("number", number);
			session.put("topicIds", newtopicIds);
		}
		return SUCCESS;
	}

	public int getTopicId() {
		return topicId;
	}

	public void setTopicId(int topicId) {
		this.topicId = topicId;
	}

}
